﻿using System.Runtime.InteropServices;

namespace GraphDrawing.Graph.Model
{
    public struct HitTestResult
    {
        public readonly BlockModel block;
        public readonly SlotModel slot;
        public readonly ConnectionModel connection;
        public readonly HitType hitType;

        HitTestResult(HitType hitType, BlockModel block, SlotModel slot, ConnectionModel connection)
        {
            this.hitType = hitType;
            this.block = block;
            this.slot = slot;
            this.connection = connection;
        }

        public static HitTestResult Block(BlockModel block)
        {
            return new HitTestResult(HitType.BLOCK, block, null, null);
        }

        public static HitTestResult Slot(SlotModel slotModel)
        {
            return new HitTestResult(HitType.SLOT, null, slotModel, null);
        }

        public static HitTestResult Connection(ConnectionModel connection)
        {
            return new HitTestResult(HitType.CONNECTION, null, null, connection);
        }

        public static HitTestResult None()
        {
            return new HitTestResult(HitType.NONE, null, null, null);
        }
    }

    public enum HitType
    {
        NONE = 0,
        BLOCK = 1,
        SLOT = 2,
        CONNECTION = 3
    }
}
